<%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>Grid show</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="cep/css/grid.css">
	<script type="text/javascript" src="cep/js/sort.js"></script>
	<script type="text/javascript" src="cep/js/grid.js"></script>
	<script type="text/javascript" src="cep/js/validation/validation.js"></script>
  <script type="text/javascript" src="cep/js/validation/form_auto_validation.js"></script>
  </head>
  <body>
  <c:if test="${dataTable == null}"><span>This page doesn't hava any data.</span></c:if><c:if test="${dataTable != null}"><span class="grid_title">${dataTable.desc }</span>
   	<br><br>
   	<c:if test="${dataTable.conditions != null}" var="hasCond">
   	<span>您可以在此输入过滤条件:</span>
   	
   	<FORM name="cep_grid_query_form" method= "post" action="grid.was">
    	<INPUT type="hidden" name="action" value="query" />
    	<INPUT type="hidden" name="id" value="${dataTable.gridId}" />
    	<input type="hidden" name="topage" value="">
	    <TABLE width="100%" cellspacing="1" cellpadding="3" style="background-color:#DDD38D">
	    <c:set var="posi" value="${-1}"></c:set>
	    <c:set value="${dataTable.condColNum}" var="rowNum"></c:set>
    	<c:forEach var="fele"  items="${dataTable.conditions}">
	    	<c:set var="fht" value="${fele.htmlType}"></c:set>
	    	<c:set var="fn" value="${fele.fieldName}"></c:set>
    		<c:set var="posi" value="${posi + 1}"></c:set>
    		<c:if test="${posi % rowNum == 0}"><tr></c:if>
    		<c:if test="${fht != 'select'}">
	    		<td>${fele.dispText}</td><TD><input type = '${fht}' name="${fn}" size="${fele.size}" limit="${fele.limits}" msg="${fele.comment}"></TD>
    		</c:if>
    		<c:if test = "${fht == 'select'}">
    			<td>${fele.dispText}</td>
    			<td><SELECT name="${fn}" <c:if test="${fele.onchange != null}">onchange = "${fele.onchange}"</c:if> limit="${fele.limits}" msg="${fele.comment}">
    				<option value="">未选择</option>
    				<c:forEach var="option" items="${fele.dispList}"><option value="${option.key}">${option.value}</option></c:forEach>
    				</SELECT></td>
    		</c:if>
	    	<c:if test="${posi % rowNum == 1}">
    			</tr>
    		</c:if>
    	</c:forEach>
    	<c:if test="${posi % rowNum != 1}">
    		<td colspan="${(posi % rowNum) * 2}"></td></tr>
    	</c:if>
	<!-- 操作按纽 -->
	<tr>
    <td colspan="2">
      <input type="button" onclick="queryData(this.form);" value="查询" id="but_quer"/>
    </td><td colspan="2"><span id="easy_mana_err_span"></span></td>
  </tr>
  </TABLE>
    </FORM>
   	</c:if>
   	<span class="page_desc">Page:${dataTable.currentPage}/${dataTable.pageCount} &nbsp;&nbsp;${fn:length(dataTable.rows)} resords. Total record:${dataTable.recordCount}</span>
   	<br>
   	<div class="${hasCond ? 'single_grid_div_cond' : 'single_grid_div'}">
   	<table cellspacing="1" cellpadding="3">
   		<!-- 输出表头 -->
   		<tr style="font-weight: bold;cursor:pointer">
   			<td onclick="sort_this_table(this)">序号</td>
   			<c:forEach items="${dataTable.th}" var="th">
   				<td onclick="sort_this_table(this)" <c:if test="${th.width != null}">width="${th.width}"</c:if>>${th.value}</td>
   			</c:forEach>
   		</tr>
   		<!-- 输出表数据 -->
   		<c:forEach items="${dataTable.rows}" var="row" varStatus="i"><tr onmousemove="mOvr(this)" onmouseout="mOut(this)" onclick="selectRow(this)">
   				<td>${i.index + 1}</td>
   				<c:forEach items="${row}" var="td" varStatus="j">
   					<td <c:if test="${td.dispMode == 'pop'}" var="isPop">onmouseover="dispTd('div_${i.index}_${j.index}')" onmouseout="hideTd('div_${i.index}_${j.index}')"</c:if><c:if test="${td.onclick != null}"> onclick=${td.onclick }</c:if><c:if test="${td.title != null}"> title="${td.title}"</c:if>><c:if test="${td.linkUrl != null}" var="hasLink"><a href="${td.linkUrl}"></c:if>${isPop ? td.goat : td.value}<c:if test="${hasLink}"></a></c:if></td>
   					<c:if test="${isPop}">
   						<div id="div_${i.index}_${j.index}" style="display:none">${td.value}</div>
   					</c:if>
   				</c:forEach>
   			</tr>
   		</c:forEach>
   	</table>
   	<DIV class="page_index">
      <c:set value="${dataTable.currentPage}" var="midder"/>
      <c:if test="${midder - 6 < 0}" var="x6">
      	<c:set value="${1}" var="start"></c:set>
      	<c:if test="${dataTable.pageCount > 10}" var="last">
      		<c:set value="${10}" var="end"></c:set>
      	</c:if>
      	<c:if test="${!last}">
      	<c:set value="${dataTable.pageCount}" var="end"></c:set>
      	</c:if>
      </c:if>
     <c:if test="${!x6}">
      	<c:if test="${midder + 5 >= dataTable.pageCount}">
      		<c:set value="${dataTable.pageCount}" var="end"></c:set>
      	</c:if>
      	<c:if test="${midder + 5 < dataTable.pageCount}" var="last">
      		<c:set value="${midder + 5}" var="end"></c:set>
      	</c:if>
      	<c:if test="${end - 10 > 0}" var="first">
      		<c:set value="${end - 10}" var="start"></c:set>
      	</c:if>
      	<c:if test="${!first}">
      		<c:set value="${1}" var="start"></c:set>
      	</c:if>
      </c:if>
      GO PAGE:<c:if test="${first}"><A href="javaScript:goPage(${1});">First</A></c:if>
      <c:forEach begin="${start}" end="${end}" var="i">
      	<c:if test="${i == dataTable.currentPage}" var="test"><A href="javaScript:goPage(${i});"><span class="page_index_current">&nbsp;${i}</span></A></c:if>
      	<c:if test="${!test}"><A href="javaScript:goPage(${i});">&nbsp;${i}</A></c:if>
      </c:forEach>
      <c:if test="${last}"><A href="javaScript:goPage(${dataTable.pageCount});">&nbsp;Last</A></c:if>
      </DIV>
   	</div>
   	<div id="display" style="position:absolute;display: block;background:#F9F8E8;width:117;height:87;padding: 7px;"></div>
   </c:if>
  </body>
</html>
